package com.loop.unclelend.ui.activity

import android.view.View
import com.loop.unclelend.base.app.AppStackManager
import com.loop.unclelend.databinding.UiLaunchBinding
import com.loop.unclelend.pro.ProActivity
import com.loop.unclelend.ui.presenter.Pre_Launch
import com.loop.unclelend.ui.view.IView_Launch
import com.loop.unclelend.utils.BarUtil
import com.loop.unclelend.utils.dialog.Dialog_Language
import com.loop.unclelend.utils.event.UncleEventHelper
import com.loop.unclelend.utils.event.UncleEventType
import com.loop.unclelend.utils.helper.SharedHelper

/**
 * UncleLend
 * @Author wwdeng
 * @CreateTime: 2024/9/2 17:54
 * @Annotation：启动页
 */
class Act_Launch : ProActivity(),IView_Launch {
    lateinit var binding: UiLaunchBinding
    private var presenter: Pre_Launch? = null

    override fun getUncleRootView(): View? {
        binding = UiLaunchBinding.inflate(layoutInflater)
        return binding.root
    }

    override fun initUncleView() {
        BarUtil.setStatusBarLightMode(this, false)
        isInterceptBack(true)
        //关闭所有页面
        AppStackManager.finishAllActivity(Act_Launch::class.java)
    }

    override fun initUncleListener() {
    }

    override fun initUncleData() {
        presenter = Pre_Launch(this)
        presenter!!.requestTimeZoneAction()
    }

    /**
     * 展示选择语言dialog
     */
    override fun showUncleTanzaniaLanguageDialog(){
        val dialog = Dialog_Language(this,"Launch Page",object : Dialog_Language.IDialogCallback{
            override fun onSubmitClick() {
                SharedHelper.saveUncleSPData(SharedHelper.UNCLE_SPKEY.UNCLE_TANZANIA_LANGUAGE,true)
                showUncleLoading()
                presenter!!.requestCommonConfigAction()
            }
        })
        dialog.setCancelable(false)
        dialog.setCanceledOnTouchOutside(false)
        dialog.show()
    }

    /**
     * 进入主页
     */
    override fun showUncleMainPage() {
        onIntent(Act_Main::class.java)
        finish()
    }

    /**
     * 进入权限页
     */
    override fun showUnclePermissionPage() {
        onIntent(Act_Permission::class.java)
        finish()
    }

    /**
     * 进入登录页
     */
    override fun showUncleLoginPage() {
        onIntent(Act_Login::class.java)
        finish()
    }

    override fun onDestroy() {
        super.onDestroy()
        UncleEventHelper.addUncleRequestEventAction(UncleEventType.PAGE.UNCLE_PAGE_LAUNCH_END)
    }
}